/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
package com.diamondsys.embrapa;

import java.util.List;
import javax.ejb.Stateless;
import javax.persistence.EntityManager;
import javax.persistence.PersistenceContext;

/**
 *
 * @author Rafael
 */
@Stateless
public class SigifEventosintFacade extends AbstractFacade<SigifEventosint> {
    @PersistenceContext(unitName = "com.diamondsys_embrapa_war_1.0-SNAPSHOTPU")
    private EntityManager em;

    @Override
    public EntityManager getEntityManager() {
        return em;
    }

    public SigifEventosintFacade() {
        super(SigifEventosint.class);
    }
    
    public List<SigifEventosint> findByClienteId(TbInst clienteId) {
        return em.createQuery(   "  SELECT s FROM SigifEventosint s, ParticipanteEvento p "
                               + "   WHERE s.ideventosint = p.participanteEventoPK.sigifEventosintIdeventosint"
                               + "     AND p.participanteEventoPK.tbInstCodInstituicao = :tbInstCodInstituicao", SigifEventosint.class)
                .setParameter("tbInstCodInstituicao", clienteId.getCodInstituicao())
                .getResultList();
    }    
    
    public List<SigifEventosint> findAll() {
        return em.createNamedQuery("SigifEventosint.findAll", SigifEventosint.class).getResultList();
    }
}
